//
//  NSString+Tool.m
//  PeitaMerchants
//
//  Created by apple on 17/7/6.
//  Copyright © 2017年 Facebook. All rights reserved.
//

#import "NSString+Tool.h"

@implementation NSString (Tool)


/**
 *  字符串转字典
 *
 *  @return 字典
 */
- (NSDictionary *)dictionaryWithJsonString {
  
  if (!self) {
    return nil;
  }
  
  NSData *jsonData = [self dataUsingEncoding:NSUTF8StringEncoding];
  NSError *err;
  NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:jsonData
                        
                                                       options:NSJSONReadingMutableContainers
                        
                                                         error:&err];
  
  if(err) {
    
    return nil;
    
  }
  
  return dict;
  
}

@end
